<?php
/**
 * Created on 29-mag-2006
 * jaco_at_pixeldump
 * inserting mp sound event
 */

include("sample_utils.php");                        // provides some utils and using mk

$sndFN = "creak_closing.mp3";
$swfFN = "soundStart.swf";
$flasmFN = "f6_sound_preload.flm";				    // flasm syntax file from where we'll inject mk assembled bytecode

$snd = new MKSoundContainer("", $sndFN);           // start a fresh sound data with soundID = 1 by default
$sndAssetTD = $snd->set_linkage_name("creak");      // we'll use as linkage sound
$sndTD = $snd->update_tagData();                    // tag data
$sndSSHTD = $snd->update_soundStreamHead();         // streaming sound settings

$as = new MKActionScriptContainer();				// actionscript container VERY EXPERIMENTAL
$frameTD1 = $as->assemble_from_file($flasmFN, 1);   // compile frame #1 (0), contain a simple blind preload
$frameTD2 = $as->assemble_from_file($flasmFN, 2);   // compile frame #2 (1), attach sound and play

$swf = new MKSwf($swfFN);                           // a fresh new swf
$swf->set_swfDir(SERVER_MKTMP);                     // we'll store in tmp
$swf->add_tagData($sndTD);                          // start to populate, sound
$swf->add_tagData($sndSSHTD);                       // ... streaming settings
$swf->add_tagData($sndAssetTD);                     // ... sound linkage
$swf->add_tagData($frameTD1);                       // ... actionscript for frame #1
$swf->add_tagData($frameTD2, 2);                    // ... actionscript form frame #2

$swf->swf_output();                                 // save

$swfHeader = $swf->fetch_assoc();                   // prepare to publish to the browser

$str = render_swf_box($swfHeader, $imgDir, false);
$str .= "<br/><strong>" .$swfFN ." created in :<br />" .SERVER_MKTMP ."</strong>";
echo show_content($str, basename(__FILE__));
?>
